Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for <any /> #29

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Add support for <any /> #29

merged 1 commit into from
Dec 19, 2024

Conversation

veewee
Copy link
Member

@veewee veewee commented Dec 6, 2024

Q A
Type bug/feature/improvement
BC Break yes/no
Fixed issues

Summary

Add support for <any />

<element name="GetCustomerDetailsResponse">
    <complexType>
        <sequence>
            <element name="customerName" type="xsd:string" />
            <element name="customerEmail" type="xsd:string" />
            <any processContents="strict" minOccurs="0" maxOccurs="3" />
        </sequence>
    </complexType>
</element>

Converts (bidirectionally) into:

^ {#1769
  +"customerName": "John Doe"
  +"customerEmail": "[email protected]"
  +"any": array:2 [
    0 => "<hello>world</hello>"
    1 => "<hello>worljohn</hello>"
  ]
}

For XML:

<x:GetCustomerDetailsResponse xmlns:x="http://example.com/customerdetails">
    <customerName>John Doe</customerName>
    <customerEmail>[email protected]</customerEmail>
    <hello>world</hello>
    <hello>worljohn</hello>
</x:GetCustomerDetailsResponse>

This is the same as how PHP's ext-soap does the encoding.
If you want to overwrite the behaviour to for example return DOM nodes directly, you can overwrite the complex type that is added by default:

$encoderRegistry->addComplexTypeConverter('http://www.w3.org/2001/XMLSchema', 'any', new \Soap\Encoding\Encoder\AnyElementEncoder())

This one can be used as a base for your own encoder.

@veewee veewee marked this pull request as draft December 6, 2024 10:30
@veewee veewee force-pushed the any branch 7 times, most recently from dd15c73 to a848a11 Compare December 19, 2024 12:08
@veewee veewee added the enhancement New feature or request label Dec 19, 2024
@veewee veewee marked this pull request as ready for review December 19, 2024 12:10
@veewee veewee merged commit b90da84 into php-soap:main Dec 19, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant